package com.TechM.get.Controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.TechM.get.Dao.JobStatusRepository;
import com.TechM.get.Domain.JobStatus;
import com.TechM.get.Service.QueryDataService;

@RestController
public class QueryDataController {
	@Autowired
	QueryDataService queryDataService;
	@Autowired
	JobStatusRepository jobStatusRepository;
	//查询并存储数据
	@RequestMapping("/save")
	public String save() {			
		List<JobStatus> list = jobStatusRepository.findAll();
		JobStatus jobStatus;
		if (list==null || list.size()==0) {
			jobStatus = new JobStatus();
		}else{
			jobStatus = list.get(0);
		}
		jobStatus.setStatus("on");
		jobStatusRepository.save(jobStatus);
		return "on";
	}
	//停止定时任务
	@RequestMapping("/stop")
	public String stop() {
		List<JobStatus> list = jobStatusRepository.findAll();
		JobStatus jobStatus;
		if (list==null || list.size()==0) {
			jobStatus = new JobStatus();
		}else{
			jobStatus = list.get(0);
		}
		jobStatus.setStatus("off");
		jobStatusRepository.save(jobStatus);
		return "off";
	}
}
